#ifndef OBJC_CONTEXT_H
#define OBJC_CONTEXT_H

#include <sobjc-commons/st.h>
#include "class.h"
#include "scope.h"

#define NULL_S                  "(void *)0"
#define TEMP_CLASS              "cls"
#define TEMP_IVAR               "ivar"
#define TEMP_INST_METH          "inst_meth"
#define TEMP_CLASS_METH         "class_meth"
#define TEMP_PROTOCOL           "protocol"
#define TEMP_PROTOCOL_REF       "protocol_ref"
#define TEMP_INST_METH_DESC     "inst_meth_desc"
#define TEMP_CLASS_METH_DESC    "class_meth_desc"
#define SEL_TABLE_VAR           "__objc_sel_table"
#define IC_TABLE_VAR            "__objc_ic_table"
#define OBJC_STR_TABLE_VAR      "__objc_str_table"
#define OBJC_STR_CLASS_VAR      "_objc_const_str_class"
#define RECV_VAR                "__objc_recv"
#define ATTR_UNUSED             "__attribute__((unused))"

typedef struct objc_line_mark        *objc_line_mark_t;

struct objc_line_mark {
  int lineno;
  char *file;
  int flags;
  objc_line_mark_t prev;
  objc_line_mark_t next;
};

extern objc_scope_t objc_root_scope;
extern objc_scope_t objc_current_scope;
extern objc_line_mark_t objc_current_line_mark;
extern objc_line_mark_t objc_recorded_line_mark;
extern int objc_parsing_column;
extern st_table_t objc_objc_str_table;
extern int objc_nobjc_strs;
extern st_table_t objc_declared_class_table;
extern int objc_in_decl_spcr_list;
extern unsigned long objc_nsend_sites;

extern objc_class_t objc_current_class;
extern BOOL objc_current_class_is_declared;
extern BOOL objc_current_class_is_abstract;
extern BOOL objc_current_class_is_sealed;

extern int objc_nimpl_classes;
extern int objc_nimpl_protocols;
extern int objc_nimpl_ivars;
extern int objc_nimpl_inst_meths;
extern int objc_nimpl_class_meths;
extern int objc_nprotocols;
extern int objc_ninst_meth_descs;
extern int objc_nclass_meth_descs;

void objc_record_line_mark(int, const char *, int);
void objc_push_line_mark(int, const char *);
void objc_pop_line_mark();
void objc_push_token_prefix(const char *);
char *objc_shift_token_prefix();
void objc_begin_decl_spcr_list();
void objc_end_decl_spcr_list();

void objc_init_scan();
int objc_parse_file(const char *);
void objc_write_init_code(FILE *);

#endif /* OBJC_CONTEXT_H */
